This is a quick post to share a tip that I taught myself a few weeks back. I'll show you how to programmatically send yourself a text (SMS) message using twilio. This is helpful when you have long-running scripts or cells in a jupyter notebook, as is often the case in most data science and machine learning exercises. Head over to the twilio website and either signup (it's free) or login if you have an existing account.

twilio signup

Once you sucessfully login, navigate to the home page of the console. https://www.twilio.com/console Look under the Account Summary for the "Account SID" and "Auth Token". You'll need to copy both of these values.

twilio console

You should automatically be assigned a free phone number here: https://www.twilio.com/console/phone-numbers/incoming

This will be the from= argument below.

Ensure the cell phone number is added here: https://www.twilio.com/console/phone-numbers/verified

I think you can only register one verified number with a free Twilio account.

This will be the to= argument below.

Now it's time to install the Python client of the Twilio library. Follow along here.

$ pip install twilio==6.0rc10
In [1]:
from twilio.rest import Client
In [2]:
client = Client("AC469ae0307794c5753c87dd2504a8567c", "yourauthtokenhere")
In [3]:
import time
time.sleep(300) # some long-running cell
# go finish laundry
client.messages.create(to="+12024321234", from_="+15555555555", body=u"jupyter cell finished")
Out[3]:

It's that easy, I'm interested to hear how you implement this neat feature!

- Kevin Arvai


Comments

comments powered by Disqus